package com.atguigu.gmall.model.list.consumer;

import com.atguigu.gmall.model.list.service.SearchService;
import lombok.extern.log4j.Log4j2;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * sku上架或下架的监听类
 * @author 搭忆长安
 * @version 1.0
 * @date 2021年07月12日 20:26
 * @ClassName:SkuUpOrDownListener
 * @Description: TODO
 */
@Component
@Log4j2
public class SkuUpOrDownListener {
    @Autowired
    private SearchService searchService;

    /**
     * 上架
     * @param msg
     */
    @RabbitListener(queues="sku_queue_2")
    public void upper(String msg){
        log.info("商品上架,商品的id为:" + msg);
        searchService.upperGoods(Long.parseLong(msg));
    }

    /**
     * 下架
     * @param msg
     */
    @RabbitListener(queues="sku_queue_1")
    public void down(String msg){
        log.info("商品下架,商品的id为:" + msg);
        searchService.lowerGoods(Long.parseLong(msg));
    }
}
